package main

import (
	"fmt"
	"runtime"
	"sync"
)

var wx sync.WaitGroup

func a() {
	defer wx.Done()
	for i := 0; i < 10; i++ {
		fmt.Println("a:", i)
	}
}

func b() {
	defer wx.Done()
	for i := 0; i < 10; i++ {
		fmt.Println("b:", i)
	}
}

func main() {
	// goroutine初始栈大小2k
	runtime.GOMAXPROCS(2) // 默认cpu的逻辑核心数，默认跑满整个cpu //线程
	fmt.Println(runtime.NumCPU())
	wx.Add(2) // 几个进程
	go a()
	go b()
	wx.Wait()
}
